#!/bin/sh
[ "$1" = --down ] || exit 1
# 防止重复启动
LOCK=/var/lock/dnsfilter.lock
[ -f $LOCK ] && exit 1
touch $LOCK

B=/tmp/dnsfilter
C=/tmp/adupdate.log
D="date +'%Y-%m-%d %H:%M:%S'"
E="curl -Lfso"
G="Download Subscribe Rules"

if [ "$2" = 1 ];then
	echo "`eval $D` [$G]" >> $C
	/usr/share/dnsfilter/dnsfilter addown >> $C
fi

echo "`eval $D` [Start DNSFilter]" >> $C;echo `eval $D` > $B/dnsfilter.updated
rm -f $LOCK
/etc/init.d/dnsfilter start &
